/* Copyright 2013-present Barefoot Networks, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

/*
 * Antonin Bas (antonin@barefootnetworks.com)
 *
 */

#ifndef BM_BM_SIM_CONTROL_ACTION_H_
#define BM_BM_SIM_CONTROL_ACTION_H_

#include <memory>
#include <string>

#include "control_flow.h"

namespace bm {

class Packet;
class ActionFn;

class ControlAction : public ControlFlowNode {
 public:
  ControlAction(const std::string &name, p4object_id_t id);

  ControlAction(const std::string &name, p4object_id_t id,
                std::unique_ptr<SourceInfo> source_info);

  void set_next_node(ControlFlowNode *next_node);

  void set_action(ActionFn *action);

  const ControlFlowNode *operator()(Packet *pkt) const override;

 private:
  ControlFlowNode *next_node{nullptr};
  ActionFn *action;
};

}  // namespace bm

#endif  // BM_BM_SIM_CONTROL_ACTION_H_
